/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.icq.gui.frame.renderer;

import java.awt.Component;
import java.awt.Font;
import java.io.File;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import org.apache.log4j.Logger;
import ru.icq.accounts.GeneralAccountjICQ;

/**
 * Перерисовка нодов дерева и встаква туда иконок.
 * @author Носов А.В.
 */
public class MyTreeCellRenderer extends DefaultTreeCellRenderer {

    // Variables declaration
    private static final Logger log = Logger.getLogger(MyTreeCellRenderer.class);
    private Icon iconJABBER = new ImageIcon("/home/nosov/Documents/Java/WEB/ICQ/trunk/icq/Themes/Default/Icons/accounts.png"); 
    // End of variables declaration

    @Override
    public Component getTreeCellRendererComponent(JTree tree,Object value, 
            boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
        
        super.getTreeCellRendererComponent(tree, value, sel, 
                expanded, leaf, row, hasFocus);
        
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
        Object o = node.getUserObject();
        if (o instanceof GeneralAccountjICQ) {
            GeneralAccountjICQ ga = (GeneralAccountjICQ) o;
            setIcon(ga.getIcon());
            setFont(getFont().deriveFont(Font.BOLD));
        }
//        
//        setIcon(iconJABBER);
//        
//        setFont(getFont().deriveFont(Font.ITALIC));
        return this;
    }
}
